﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using AtletIS.DomainModel.Entities.Main;
using AtletIS.Repository.UnitOfWork;
using AtletIS.Service.Base;

namespace AtletIS.Service.Services
{
    public class CompetitionService : ServiceBase
    {
        #region Constructor

        public CompetitionService()
        {
            this._unitOfWork = new UnitOfWork();
        }

        public CompetitionService(IUnitOfWork unitOfWork)
        {
            this._unitOfWork = unitOfWork;
        }

        #endregion
        
        public Competition GetById(int competitionId)
        {
            return this._unitOfWork.Repository<Competition>()
                    .Query(c => c.ID == competitionId)
                    .Select()
                    .FirstOrDefault();
        }

        public Competition GetActive()
        {
            return this._unitOfWork.Repository<Competition>()
                .Query(c => c.Active == true)
                .Select()
                .FirstOrDefault();
        }

    }
}
